<?php
if(isset($_POST['ddid']))
{
require("includes/basic.php");
$cid=$_POST['ddid'];
$custid=$_POST['custid'];
$c=$custid;
$delete=mysql_query("delete from client_contact where contact_id='$cid'");
}

$class="evenrowbg";
$sr=1;
$contacts= mysql_query("select * from client_contact where client_id='$c'");
if(mysql_num_rows($contacts)>0)
{
?>
<form id='viewclientcontacts'> 
<input type='hidden' name='custid' id="custid" value="<?php echo $c; ?>">
	<table width='100%' cellpadding='1' cellspacing='0' class='list'>
	<tr>
		<th width='5%' style='white-space: nowrap;'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Sr no.</span>
			</div>
		</th>
        <th width='4%' style='white-space: nowrap;'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Edit</span>
			</div>
		</th>
		<th width='11%' style='white-space: nowrap;' align='center'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Contact Name</span>
			</div>
		</th>
		<th width='7%' style='white-space: nowrap;'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Phone 1</span>
			</div>
		</th>
		<th width='7%' style='white-space: nowrap;' align='center'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Phone 2</span>
			</div>
		</th>
		<th width='7%' style='white-space: nowrap;' align='center'>
			<div style='display:block; width: 20px;'>
				<span class="link linkdisabled">Email 1</span>
			</div>
		</th>
		<th width='7%' style='white-space: nowrap;' align='center'>
			<span class="link linkdisabled">Email 2</span>
		</th>
		<th width='10%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Contact Address</span>
		</th>
		<th width='10%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Record Status</span>
		</th>
		<th width='15%' style='white-space: nowrap;'>
			<span class="link linkdisabled">Contact Created On</span>
		</th>
		<th width='5%' class='select'>
			
<input type='checkbox' class='checkbox' name='allCheck' id='listSelectAll'>
		</th>
	</tr>
	<?php while($clientsr=mysql_fetch_array($contacts))
	{
		$contactid=$clientsr['contact_id'];
		$contactname=$clientsr['contact_name'];
		$contact_phone_1=$clientsr['contact_phone_1'];
		$contact_phone_2=$clientsr['contact_phone_2'];
		//$pass=base64_decode($clientsr['password']);
		$contact_email_1=$clientsr['contact_email_1'];
		$contact_email_2=$clientsr['contact_email_2'];
		$contact_address=substr($clientsr['contact_address'], 0, 40);
		$record_status=$clientsr['record_status'];
		$createdon=$clientsr['contact_created_on'];	
		if($class=="evenrowbg")
		{
			$class="oddrowbg";
		}
		else
		{
			$class="evenrowbg";
		}
		echo "<tr class='$class'><td style='text-align:center;'>$sr</td>";
		echo "<td style='text-align:center;'><a href='edit-client-contact.php?clid=$contactid'><img src='images/edit.png'/></a></td>";
		//echo "<td style='text-align:center;'><a href='view-client-contacts.php?clid=$contactid'><img src='images/user.png'/></a></td>";
		echo "<td>".$contactname."</td><td>".$contact_phone_1."</td><td>".$contact_phone_2."</td><td>".$contact_email_1."</td><td>".$contact_email_2."</td>";
		
		echo "<td>".$contact_address."</td>";
		
		if($record_status=='Y')
		{
			echo "<td>Yes</td>";
		}
		else
		{
			echo "<td>No</td>";
		}
		echo "<td>".$createdon."</td>";
		echo "<td style='text-align:center;'><input type='checkbox' value='$contactid' id='conid' name='chkName'></td>";
		$sr++;
		echo "</tr>";
	}

	?>
    </form>

</table>

<?php
}
else 
{
echo "no contacts added";
}

?>